home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / utilities / amake_v1.00.lha / amake.doc next >
Encoding:
Text File  |  1994-11-02  |  12.6 KB  |  392 lines

  1. /* makefile documentation tabs=4 */
  2.  
  3.                **************************************************
  4.  
  5.                                    make V1.0
  6.  
  7.                         Written by Alexis WILKE (c) 1994
  8.  
  9.                **************************************************
  10.  
  11.                     Contact: alexis@netcom.com
  12.  
  13.  
  14.  
  15.     Usage: %s [-<opts>] [varname=val] [<target>]\n", argv[0]);
  16.       where opts are:\n");
  17.         -ab                auto-build (see -u)
  18.         -ad                auto-default (always do the .DEFAULT)
  19.         -as                auto-space
  20.         -B                not compatible with old makefile (default)
  21.         -b                compatible with old makefile
  22.         -E <level>        defines the error level which stop the process
  23.         -e                forces the environment variable to override internal variables
  24.         -f <filename>    gives the descriptive file name
  25.         -h or -?        displays help screen
  26.         -i                ignores command line errors
  27.         -k                creates all possible entries without errors
  28.         -n                no command execution
  29.         -P                all files are precious and none will be deleted
  30.         -p                prints target and macro definitions
  31.         -q                returns TRUE (%d) if the target needs to be updated
  32.         -r                suppresses the effect of internal .SUFFIX
  33.         -s                silent
  34.         -t                touch the targets (no command execution)
  35.         -u                build all targets unconditionnally
  36.         -v                verbose (include all following verbose)
  37.         -vd                target/dependency check verbose
  38.         -vt                target verbose
  39.         -vv                variable verbose
  40.       where <varname>=<val> is an external variable definition
  41.       where <name> is the target to be generated
  42.             if no name is defined then the .DEFAULT is used instead
  43.             the default is \"all\" or the environment variable TARGET
  44.  
  45.       note: several options can be defined after the same dash except the one
  46.             which receive some additional informations. And any additional
  47.             information can be written just after the option letter. There
  48.             is an example:
  49.  
  50.                 -eipfmkfl -> -e -i -p -f mkfl
  51.  
  52.  
  53.     Targets:
  54.  
  55.         The target are defined before one or two colons (:). The colons are
  56.         followed by dependencies. If the target is older than one or more of
  57.         the dependencies then it is 'rebuild,' and for this purpose the
  58.         following command lines are executed like if you were typing them
  59.         into a shell.
  60.  
  61.             <targets>:[:] <denpendencies>
  62.                     <command lines>
  63.  
  64.         If the name of the target has to include a colon, it will be written
  65.         with a preceding backslash (\) or between quotes (" or ').
  66.  
  67.         Each target can appear only once, except for '::' because the target
  68.         is a library. In which case the file within the library will be checked
  69.         instead...
  70.  
  71.         If no dependency is defined, the target is automatcally supposed out
  72.         of date and will be rebuild. We often use the following rule:
  73.  
  74.             cleanup:
  75.                 -rm *.o                # created by cc
  76.                 -rm grammar.c        # created by yacc
  77.  
  78.         to delete all files which are not necessary and then have some free
  79.         disk space... (the '-' forbid errors to stop make)
  80.  
  81.         make has some internal rules (see below) which does not have to be
  82.         retyped. If they are retyped then you will suppress the effect of
  83.         the internal rule. The option -r can also be used to suppress the
  84.         effect of all internal rules.
  85.  
  86.     Macros:
  87.  
  88.         Macros are defined with the equal (=) sign. Usually one name on the
  89.         left side and a list of words on the right side of the equal. This make
  90.         also supports several name definition at the same time:
  91.  
  92.             a b c = d e f
  93.  
  94.             <name>=<string>
  95.  
  96.         then a, b and c macros all receive "d e f". Of couse a single name
  97.         is valid and the previous line could be:
  98.  
  99.             a = d e f
  100.             b = d e f
  101.             c = d e f
  102.  
  103.         To recall the contains of a macro you can use $(<name>) where the
  104.         parenthesis are not necessary when the macro as a one letter name.
  105.         Macros can contain macros: $($(<name>)) for instance... The previous
  106.         line could have been:
  107.  
  108.             z = b
  109.             a = d e f
  110.             b = $a                get $a also d e f
  111.             c = $($(z))            get $z also b and then $b also $a then d e f
  112.  
  113.         The macimum number of macros used within a macro is very hard to
  114.         determine; however it is around 30.
  115.  
  116.         make supports an automatic transformation of the words available
  117.         into a macro. Words are any string of caracters separated by one or
  118.         more spaces ( ) or a tabulation (\t). For this the long syntax
  119.         (parenthesis) is necessary:
  120.  
  121.                 $(<name>:[:][<match>][=[<trans>]])
  122.  
  123.         This syntax will take all words which match <match> and transform
  124.         them with <trans>, other words are just copied (single colon) or
  125.         dropped (double colon.) If <match> is an empty string, all words
  126.         from the source will be transformed.
  127.  
  128.         Example:   $(OBJECTS::.o=.c)
  129.  
  130.         It transforms all object file names finishing by '.o' into a '.c'
  131.         and suppress all other names.
  132.  
  133.         The <match> and <trans> patterns can be complex and include:
  134.  
  135.                                             <match>    <trans>
  136.             character (A-Z, a-z, etc...)      Yes      Yes
  137.             asterisk (*)                      Yes      Yes
  138.             question mark (?)                  Yes      Yes
  139.             range ([<from>-<to>])              Yes      No
  140.             not-range ([^<from>-<to>])          Yes      No
  141.             multiple range ([...]*)              Yes      No
  142.             multiple not-range ([^...]*)      Yes      No
  143.             not (^<letter>)                      Yes      No
  144.             skip (^)                          No      Yes
  145.  
  146.             . characters from match will be erased from the source word and
  147.               must perfectly match the source string; characters from the
  148.               transformation pattern are copied as is into the resulting string;
  149.  
  150.             . an asterisk will be used to replace any pattern of any character;
  151.               when present into the match pattern, the transformation pattern
  152.               can use any other pattern character (? and ^) to get a character;
  153.               when present into the transformation pattern, all remaining
  154.               character from the last pattern character are copied;
  155.               the empty pattern is a valid match for an asterisk;
  156.  
  157.             . a question mark will be used to replace any one character; the
  158.               character must exist;
  159.  
  160.             . a range can be a single character, when defined by it-self and
  161.               a repeated range, when followed by an asterisk; the asterisk
  162.               has the same effect and also the empty pattern is a valid match;
  163.               a range contents can be inverted when it starts with a '^'
  164.               character;
  165.  
  166.             . the not is a single character preceded by a '^' character; this
  167.               enables any character except the one specified;
  168.  
  169.             . the skip can be used only into the transformation pattern and
  170.               will skip a caracter from the source;
  171.  
  172.             . combinaison are not actually available: ([A-Z]*|foo) is not
  173.               possible;
  174.  
  175.         Range definition is similaire to the one defined for 'grep' or 'lexx'.
  176.         Also you can define any letter with: [A-Za-z]. You can define any 'legal'
  177.         file name with:
  178.  
  179.                 [A-Za-z0-9_&.]*
  180.  
  181.         This is any upper or lower case letter plus all digits and the characters
  182.         underscore (_) the ampersand (&) and the point (.).
  183.  
  184.         Then an equivalent to $(OBJECT::.o=.c) is:
  185.  
  186.                 $(OBJECTS::*.o=*.c)
  187.  
  188.         The following will add a '.c' suffix to any five letters word. Other
  189.         words are not modified:
  190.  
  191.                 $(OBJECTS:?????=.c)
  192.  
  193.         The order in which macros are defined is important. A macro can call
  194.         it-self, also its previous definition, thus:
  195.  
  196.             a = b
  197.             a = $a c
  198.             a = $(a) d
  199.  
  200.         is an equicalent to:   a = b c d
  201.  
  202.         The shell can automatically be invoked through a macro with the
  203.         use of the back-cote (`), and for instance you may type:
  204.  
  205.             OBJECTS = `ls >%s *.c`            # get source file names
  206.             OBJECTS = $(OBJECTS:.c=.o)        # we have object file names
  207.  
  208.         where the '%s' will be changed into the destination file name. The
  209.         destination will be a temporary file. The syntax '-o %s' for the
  210.         destination definition is perfectly valid.
  211.  
  212.         The shell also be invoked with a command line has been written
  213.         between { and }. However, make will execute the command line
  214.         every time the macro is invoked, when the back-cote is used (`)
  215.         the command line is executed only once.
  216.  
  217.         note: make always generates the macros in real time. Also if you
  218.               change some environment variables, you can change the macro
  219.               expansion! However it might not work on all unix machines...
  220.               But define macros between rules (traget-dependency-command)
  221.               as no effect. make manage all macros as if they were defined
  222.               at the beginning of the script file.
  223.  
  224.             foo.o: foo.c
  225.                 setenv CFLAGS -O
  226.                 $(CC) $(CFLAGS) -o $@ $<    # cc -O -o foo.o foo.c
  227.                 setenv CFLAGS
  228.  
  229.     Special Targets:
  230.  
  231.         <targets> .IGNORE: [<dependencies>]
  232.  
  233.                 will be used to turn on the -i option and also ignore all
  234.                 errors of executed commands for this list of command. This
  235.                 is not a general switch like -i. You may use the dash (-)
  236.                 in front of the command rather than .IGNORE. This way you
  237.                 can select each command line which can and which can not
  238.                 stop the process.
  239.  
  240.                 For instance:
  241.  
  242.                     cleanup .IGNORE:
  243.                         delete >NIL: *.o
  244.  
  245.         <targets> .SILENT: [<dependencies>]
  246.  
  247.                 will turn off the verbose mode and all command lines will
  248.                 not be displayed for this list of command. This is not a
  249.                 general switch like -s.
  250.  
  251.         .DEFAULT: <dependencies>
  252.  
  253.                 will be used when make has been called without target or
  254.                 if the a target does not have all the necessary dependencies.
  255.                 By default this is:
  256.  
  257.                         .DEFAULT: all
  258.  
  259.         .PRECIOUS: <dependencies>
  260.  
  261.                 will be used to keep the specified dependency files,
  262.                 otherwise make will delete those files before it quits.
  263.  
  264.         Note: .SILENT and .IGNORE can be defined anywhere within the
  265.               target list and both may appear in the same list.
  266.  
  267.     Command lines:
  268.  
  269.         Command lines may starts with one or both of - and @, in any order.
  270.         The @ will disable the printing of the command line (like if the
  271.         -s option was specified.) And the - sign is an equivalent of
  272.         -i option for this command line, also errors will not be checked.
  273.  
  274.         The double quotes (") remain unmodified on command lines.
  275.  
  276.     Default rules:
  277.  
  278.         Make has the following default rules available for use by anyone.
  279.         If you redefine them you will hide those internal definitions.
  280.  
  281.         .c:
  282.             $(CC) $(CCFLAGS) $(CFLAGS) -o $@ $<
  283.  
  284.         .c.o:
  285.              $(CC) -c $(CCFLAGS) $(CFLAGS) -o $@ $<
  286.  
  287.         .s:
  288.              $(AS) $(ASFLAGS) $(AFLAGS) -o $@ $<
  289.  
  290.         .y:
  291.              $(YACC) $(YACCFLAGS) $(YFLAGS) -o $@ $<
  292.  
  293.         .l:
  294.             $(LEX) $(LEXFLAGS) $(LFLAGS) -o $@ $<
  295.  
  296.         .f:
  297.             $(FORTRAN) $(FFLAGS) -o $@ $<
  298.  
  299.         .p:
  300.             $(PASCAL) $(PFLAGS) -o $@ $<
  301.  
  302.         .o:
  303.             $(LD) $(LDFLAGS) -o $@ $<
  304.  
  305.         .asm.s:
  306.             $(ASM) $(ASMFLAGS) $(LFLAGS) -o $@ $<
  307.  
  308.  
  309.     Suffixes:
  310.  
  311.         Make automatically handles suffixes (termination of file names.)
  312.  
  313.         A target will be searched in each plain dependency before to be
  314.         checked in suffixes dependency. Suffixes dependencies are defined
  315.         as:
  316.  
  317.             .{letter}+(.{letter}+)?: <dependency files>
  318.                     <command lines>
  319.  
  320.         For instance to compile C like programs:
  321.  
  322.             .c.o:
  323.                 $(CC) -c $(CFLAGS) -o $@ $<
  324.  
  325.         The variable .SUFFIXES hold suffixes dependencies. A C program for
  326.         instance will usuly be compiled into an object file. The default
  327.         .SUFFIXES variable contains:
  328.  
  329.             .c.o        C source file
  330.             .s.o        assembler source file
  331.             .f.o        fortran source file
  332.             .p.o        pascal source file
  333.             .asm.s        high level assembler source file
  334.             .y.c        yacc source file
  335.             .l.c        lex source file
  336.             .o            object file
  337.             .a            archive file
  338.             .h            header file
  339.             .sh            shell file
  340.  
  341.         The usage of the a single suffixe enables the compilation from
  342.         a suffixed file to a file without suffixe:
  343.  
  344.             .c:
  345.                 $(CC) $(CFLAGS) -o $@ $<
  346.  
  347.         this line transform '.c' files in executables (CFLAGS should never
  348.         include the flag '-c'.)
  349.  
  350.     Internal variables:
  351.  
  352.         $(CDW)            the working directory when make started
  353.         $(FILENAME)        make script file name
  354.         $(VERSION)        version of the make
  355.         $(VPATH)        extra paths checked after the current directory
  356.         $(SHELL)        shell used to execute commands (default "/bin/sh")
  357.         $(STOPLEVEL)    error value at which the process is stopped
  358.         $(FAILLEVEL)    error value at which the process is aborted
  359.         $(TARGETS)        default (and usuly external) targets
  360.         $(NAMES)        list of targets defined on the command line
  361.  
  362.         Executable    Flags (*)        Note
  363.  
  364.         $(MAKE)        $(MAKEFLAGS)    this tool name
  365.         $(CC)        $(CFLAGS)        C compiler name (default: "cc")
  366.                     $(CCFLAGS)
  367.         $(LD)        $(LDFLAGS)        linker name (default: "ld")
  368.         $(AS)        $(AFLAGS)        assembler name (default: "as")
  369.                     $(ASFLAGS)
  370.         $(AR)        $(ARFLAGS)        archiver (default: "ar")
  371.         $(LEX)        $(LEXFLAGS)        lexical compiler (default: "lex")
  372.         $(YACC)        $(YACCFLAGS)    yacc compiler (default: "yacc")
  373.         $(GET)        $(GETFLAGS)        get tool (default: "get")
  374.         $(ASM)        $(ASMFLAGS)        high level assembler name (default: "asm")
  375.         $(FORTRAN)    $(FFLAGS)        fortran compiler name (default: "fortran")
  376.                     $(FORTRANFLAGS)
  377.         $(PASCAL)    $(PFLAGS)        pascal compiler name (default: "pascal")
  378.                     $(PASCALFLAGS)
  379.  
  380.     (*) by default flags are undefined, except $(MAKEFLAGS) which receive all
  381.         flags which have been used on the command line
  382.  
  383.  
  384.     Special features:
  385.  
  386.         If the script starts with a sharp (#) and an exclamation mark (!) the
  387.         following name is an alternative file maker ('#!<make name>'.)
  388.         The alternative file maker will be executed only if it is not it-self
  389.         and if it is available. The default is also: '#!make'.
  390.  
  391.  
  392.